﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CodeGame.ServerObjects;

namespace CodeGame.Networking.Serverside.ClientServerPackets
{
    class EntityTintPacket : ServerPacket
    {
        public override ClientServerNet GetID()
        {
            return ClientServerNet.EntityTintRequest;
        }

        public override void Handle(Lidgren.Network.NetIncomingMessage message, Lidgren.Network.NetConnection sender)
        {
            string id = message.ReadString();
            int r = message.ReadInt32();
            int g = message.ReadInt32();
            int b = message.ReadInt32();

            Player ply = ServerSingletons.Players.GetPlayer(sender);
            if (ply.WithdrawResouces(Balence.TintEntity))
            {
                ServerSingletons.World.GetEntity(true, id).Tint(id, r, g, b);
            }
        }
    }
}
